#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 21-3-29 下午4:47
# @Author  : zgd
# @Site    : 
# @File    : __init__.py.py
# @Software: PyCharm

from flask import Blueprint
from flask import redirect
from flask import request
from flask import session

admin_blue = Blueprint("admin_blue",__name__,url_prefix="/admin")


from . import views


# 请求钩子拦截用户请求

#１ 拦截普通用户,拦截admin_blue装饰的请求
@admin_blue.before_request
def before_request():
    # １．判断访问的是否　非登录页面
    # if request.url.endswith("/admin/login"):
    #     pass
    # else:
    #     # ２．判断是不是管理员
    #     if session.get("is_admin"):
    #         pass
    #     else:
    #         return redirect("/")

   # print(request.url) #拦截到admin_blue装饰的请求，不拦截普通用户的请求
    if not request.url.endswith("admin/login"):
        if not session.get("is_admin"):
            return redirect("/")










